﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:fp="clr-namespace:ForumsBrowser">
    
    <!-- ImageToken -->

    <fp:ImageConverter x:Key="ImageConverter"/>
    <fp:ThreadColorConverter x:Key="ThreadColorConverter"/>
    <fp:DateTimeTextConverter x:Key="DateTimeTextConverter"/>
    <fp:NotBooleanToVisibilityConverter x:Key="NotBoolVis"/>
    <BooleanToVisibilityConverter x:Key="BoolVis"/>
    <fp:ThreadToAnswerTextFormatter x:Key="answererFormatter"/>
    <fp:DoublePercentConverter x:Key="DoublePercentConverter"/>
    <fp:DoubleDivideByTwoConverter x:Key="DoubleDivideByTwoConverter"/>
    
    <Style TargetType="Border" x:Key="ImageTokenBorderStyle">
        <Setter Property="CornerRadius" Value="5,5,5,5"/>
        <Setter Property="Background" Value="Black"/>
        <Setter Property="BorderThickness" Value="1"/>
        <Setter Property="Padding" Value="1"/>
        <Setter Property="BorderBrush">
            <Setter.Value>
                <LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
                    <LinearGradientBrush.GradientStops>
                        <GradientStop Color="White" Offset="1"/>
                        <GradientStop Color="DarkGray"/>
                    </LinearGradientBrush.GradientStops>
                </LinearGradientBrush>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="{x:Type fp:ImageToken}">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="UserControl">
                    <Border Width="{Binding RelativeSource={RelativeSource Self}, Path=ActualHeight}" Style="{StaticResource ImageTokenBorderStyle}">
                        <ContentPresenter/>
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <!-- MedalControl -->
    
    <Style TargetType="{x:Type fp:MedalControl}">
        <Setter Property="Edge" Value="White"/>
        <Setter Property="FillBrush" Value="Yellow"/>
    </Style>
    
    <!-- ThreadListItem -->
    
    <Style TargetType="{x:Type fp:ThreadListItem}">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="UserControl">
                    <Border CornerRadius="5,5,5,5" Padding="2,2,2,2" BorderThickness="1.5" HorizontalAlignment="Stretch" >
                        <Border.BorderBrush>
                            <LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
                                <LinearGradientBrush.GradientStops>
                                    <GradientStop Color="White" Offset="1"/>
                                    <GradientStop Color="Gray"/>
                                </LinearGradientBrush.GradientStops>
                            </LinearGradientBrush>
                        </Border.BorderBrush>
                        <Border.Background>
                            <LinearGradientBrush StartPoint="0,0" EndPoint="0,.7">
                                <LinearGradientBrush.GradientStops>
                                    <GradientStop Color="Black" Offset="1" />
                                    <GradientStop Color="{Binding Converter={StaticResource ThreadColorConverter} }" Offset="-.6" />
                                </LinearGradientBrush.GradientStops>
                            </LinearGradientBrush>
                        </Border.Background>
                        <ContentPresenter/>
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    
    <!-- Mini Thread List Item-->
    
    <Style TargetType="{x:Type fp:ThreadListSummaryItem}">
        <Setter Property="Height" Value="52"/>
        <Setter Property="MinWidth" Value="100"/>
        <Setter Property="Background" Value="Transparent"/>
        <Setter Property="HorizontalAlignment" Value="Stretch"/>
        <Setter Property="Margin" Value="0,2,4,5"/>
        <Setter Property="ToolTip">
            <Setter.Value>
                <ControlTemplate TargetType="UserControl">
                    <fp:ThreadTooltip/>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="UserControl">
                    <Grid>
                        <Border CornerRadius="5,5,5,5" Padding="2,1,1,1" BorderThickness="1.5" HorizontalAlignment="Stretch" >
                            <Border.BorderBrush>
                                <LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
                                    <LinearGradientBrush.GradientStops>
                                        <GradientStop Color="White" Offset="1"/>
                                        <GradientStop Color="Gray"/>
                                    </LinearGradientBrush.GradientStops>
                                </LinearGradientBrush>
                            </Border.BorderBrush>
                            <Border.Background>
                                <LinearGradientBrush StartPoint="0,0" EndPoint="0,.7">
                                    <LinearGradientBrush.GradientStops>
                                        <GradientStop Color="Black" Offset="1" />
                                        <GradientStop Color="{Binding Converter={StaticResource ThreadColorConverter} }" Offset="-.6" />
                                    </LinearGradientBrush.GradientStops>
                                </LinearGradientBrush>
                            </Border.Background>
                            <ContentPresenter/>
                        </Border>
                        <fp:NewThreadNotification HorizontalAlignment="Left"
                                                  Height="20" VerticalAlignment="Top"
                                                  Visibility="{Binding Path=IsNew, Converter={StaticResource BoolVis} }"
                                                  Margin="2,3,0,0"/>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    
    <!-- TextBlock and DateBlock -->
    
    <Style TargetType="TextBlock">
        <Setter Property="Foreground" Value="White"/>
        <Setter Property="TextTrimming" Value="CharacterEllipsis"/>
    </Style>

    <Style TargetType="{x:Type fp:DateBlock}">
        <Setter Property="Foreground" Value="White"/>
        <Setter Property="TextTrimming" Value="CharacterEllipsis"/>
    </Style>

    <!-- Selected Forums Title -->

    <Style TargetType="Label" x:Key="SelectedForumsTitle">
        <Setter Property="SnapsToDevicePixels" Value="True" />
        <Setter Property="Foreground" Value="Black" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="Label">
                    <Border Margin="2,2,2,2" BorderBrush="#40FFFFFF" CornerRadius="8,8,8,8" BorderThickness="1" HorizontalAlignment="Stretch">
                        <Border CornerRadius="7,7,7,7" BorderBrush="Black" BorderThickness="1" VerticalAlignment="Stretch" HorizontalAlignment="Stretch">
                            <Border.Background>
                                <LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
                                    <LinearGradientBrush.GradientStops>
                                        <GradientStop Color="White" />
                                        <GradientStop Color="#BBBBBB" Offset="0.50" />
                                        <GradientStop Color="#999999" Offset="0.51" />
                                        <GradientStop Color="#999999" Offset="0.65" />
                                        <GradientStop Color="#CCCCCC" Offset="1" />
                                    </LinearGradientBrush.GradientStops>
                                </LinearGradientBrush>
                            </Border.Background>
                            <Border BorderThickness="1" CornerRadius="6,6,6,6" BorderBrush="#80FFFFFF">
                                <ContentPresenter  Margin="3,5,2,5" />
                            </Border>
                        </Border>
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    
    <!-- ORANGE STYLE FOR DAVID TO CHECK OUT -->
    <!--
    <Style TargetType="Label" x:Key="SelectedForumsTitle">
        <Setter Property="SnapsToDevicePixels" Value="True" />
        <Setter Property="Foreground" Value="White" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="Label">
                    <Border Margin="2,2,2,2" BorderBrush="#40FFFFFF" CornerRadius="8,8,8,8" BorderThickness="1" HorizontalAlignment="Stretch">
                        <Border CornerRadius="7,7,7,7" BorderBrush="#4A2E10" BorderThickness="1" VerticalAlignment="Stretch" HorizontalAlignment="Stretch">
                            <Border.Background>
                                <LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
                                    <LinearGradientBrush.GradientStops>
                                        <GradientStop Color="#D2822D" />
                                        <GradientStop Color="#7F4F1B" Offset="0.50" />
                                        <GradientStop Color="#4A2E10" Offset="0.51" />
                                        <GradientStop Color="#4A2E10" Offset="0.65" />
                                        <GradientStop Color="#7F4F1B" Offset="1" />
                                    </LinearGradientBrush.GradientStops>
                                </LinearGradientBrush>
                            </Border.Background>
                            <Border BorderThickness="1" CornerRadius="6,6,6,6" BorderBrush="#80FFC98F">
                                <ContentPresenter  Margin="3,5,2,5" />
                            </Border>
                        </Border>
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    -->
    <!-- ToggleButton -->
    
    <Style TargetType="ToggleButton">
        <Setter Property="OverridesDefaultStyle" Value="True" />
        <Setter Property="SnapsToDevicePixels" Value="True" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="ToggleButton">
                    <Border Margin="2,2,2,2" BorderBrush="#40FFFFFF" CornerRadius="8,8,8,8" BorderThickness="1" HorizontalAlignment="Stretch">
                        <Border CornerRadius="7,7,7,7" BorderBrush="Black" BorderThickness="1" VerticalAlignment="Stretch" HorizontalAlignment="Stretch">
                            <Border.Background>
                                <LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
                                    <LinearGradientBrush.GradientStops>
                                        <GradientStop Color="#686868" />
                                        <GradientStop Color="#272727" Offset="0.50" />
                                        <GradientStop Color="Black" Offset="0.51" />
                                        <GradientStop Color="Black" Offset="0.65" />
                                        <GradientStop Color="#363636" Offset="1" />
                                    </LinearGradientBrush.GradientStops>
                                </LinearGradientBrush>
                            </Border.Background>
                            <Border BorderThickness="1" CornerRadius="6,6,6,6" BorderBrush="#80FFFFFF">
                                <Grid ClipToBounds="True" Name="ContentGrid">
                                    <Ellipse Name="Light" Visibility="Hidden">
                                        <Ellipse.RenderTransform>
                                            <TransformGroup>
                                                <ScaleTransform ScaleY="2"/>
                                                <ScaleTransform CenterX="{Binding Path=ActualWidth, Converter={StaticResource DoubleDivideByTwoConverter}, ElementName=ContentGrid}" CenterY="{Binding Path=ActualHeight, ElementName=ContentGrid}" ScaleX="1.4" ScaleY="1.4" />
                                            </TransformGroup>
                                        </Ellipse.RenderTransform>
                                        <Ellipse.Fill>
                                            <RadialGradientBrush>
                                                <RadialGradientBrush.GradientStops>
                                                    <GradientStop Color="#40FFFFFF" />
                                                    <GradientStop Color="Transparent" Offset="1" />
                                                </RadialGradientBrush.GradientStops>
                                            </RadialGradientBrush>
                                        </Ellipse.Fill>
                                    </Ellipse>
                                    <ContentPresenter  Margin="3,5,2,5" />
                                </Grid>
                            </Border>
                        </Border>
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsChecked" Value="True">
                            <Setter TargetName="Light" Property="Visibility" Value="Visible" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <!-- Fill Brushes -->

    <LinearGradientBrush x:Key="NormalBrush" StartPoint="0,0" EndPoint="0,1">
        <GradientBrush.GradientStops>
            <GradientStopCollection>
                <GradientStop Color="#000" Offset="0.0"/>
                <GradientStop Color="#888" Offset="1.0"/>
            </GradientStopCollection>
        </GradientBrush.GradientStops>
    </LinearGradientBrush>

    <LinearGradientBrush x:Key="HorizontalNormalBrush" StartPoint="0,0" EndPoint="1,0">
        <GradientBrush.GradientStops>
            <GradientStopCollection>
                <GradientStop Color="#000" Offset="0.0"/>
                <GradientStop Color="#888" Offset="1.0"/>
            </GradientStopCollection>
        </GradientBrush.GradientStops>
    </LinearGradientBrush>

    <LinearGradientBrush x:Key="LightBrush" StartPoint="0,0" EndPoint="0,1">
        <GradientBrush.GradientStops>
            <GradientStopCollection>
                <GradientStop Color="#444" Offset="0.0"/>
                <GradientStop Color="#AAA" Offset="1.0"/>
            </GradientStopCollection>
        </GradientBrush.GradientStops>
    </LinearGradientBrush>

    <LinearGradientBrush x:Key="HorizontalLightBrush" StartPoint="0,0" EndPoint="1,0">
        <GradientBrush.GradientStops>
            <GradientStopCollection>
                <GradientStop Color="#444" Offset="0.0"/>
                <GradientStop Color="#AAA" Offset="1.0"/>
            </GradientStopCollection>
        </GradientBrush.GradientStops>
    </LinearGradientBrush>

    <LinearGradientBrush x:Key="DarkBrush" StartPoint="0,0" EndPoint="0,1">
        <GradientBrush.GradientStops>
            <GradientStopCollection>
                <GradientStop Color="#FFF" Offset="0.0"/>
                <GradientStop Color="#AAA" Offset="1.0"/>
            </GradientStopCollection>
        </GradientBrush.GradientStops>
    </LinearGradientBrush>

    <LinearGradientBrush x:Key="PressedBrush" StartPoint="0,0" EndPoint="0,1">
        <GradientBrush.GradientStops>
            <GradientStopCollection>
                <GradientStop Color="#000" Offset="0.0"/>
                <GradientStop Color="#666" Offset="0.1"/>
                <GradientStop Color="#666" Offset="0.9"/>
                <GradientStop Color="#888" Offset="1.0"/>
            </GradientStopCollection>
        </GradientBrush.GradientStops>
    </LinearGradientBrush>

    <SolidColorBrush x:Key="DisabledForegroundBrush" Color="#888" />

    <SolidColorBrush x:Key="DisabledBackgroundBrush" Color="#EEE" />

    <SolidColorBrush x:Key="WindowBackgroundBrush" Color="#FFF" />

    <SolidColorBrush x:Key="SelectedBackgroundBrush" Color="#DDD" />

    <!-- Border Brushes -->

    <LinearGradientBrush x:Key="NormalBorderBrush" StartPoint="0,0" EndPoint="0,1">
        <GradientBrush.GradientStops>
            <GradientStopCollection>
                <GradientStop Color="#555" Offset="0.0"/>
                <GradientStop Color="#888" Offset="1.0"/>
            </GradientStopCollection>
        </GradientBrush.GradientStops>
    </LinearGradientBrush>

    <LinearGradientBrush x:Key="HorizontalNormalBorderBrush" StartPoint="0,0" EndPoint="1,0">
        <GradientBrush.GradientStops>
            <GradientStopCollection>
                <GradientStop Color="#CCC" Offset="0.0"/>
                <GradientStop Color="#444" Offset="1.0"/>
            </GradientStopCollection>
        </GradientBrush.GradientStops>
    </LinearGradientBrush>

    <LinearGradientBrush x:Key="DefaultedBorderBrush" StartPoint="0,0" EndPoint="0,1">
        <GradientBrush.GradientStops>
            <GradientStopCollection>
                <GradientStop Color="#777" Offset="0.0"/>
                <GradientStop Color="#000" Offset="1.0"/>
            </GradientStopCollection>
        </GradientBrush.GradientStops>
    </LinearGradientBrush>

    <LinearGradientBrush x:Key="PressedBorderBrush" StartPoint="0,0" EndPoint="0,1">
        <GradientBrush.GradientStops>
            <GradientStopCollection>
                <GradientStop Color="#444" Offset="0.0"/>
                <GradientStop Color="#888" Offset="1.0"/>
            </GradientStopCollection>
        </GradientBrush.GradientStops>
    </LinearGradientBrush>

    <SolidColorBrush x:Key="DisabledBorderBrush" Color="#AAA" />

    <SolidColorBrush x:Key="SolidBorderBrush" Color="#888" />

    <SolidColorBrush x:Key="LightBorderBrush" Color="#AAA" />

    <!-- Miscellaneous Brushes -->
    <SolidColorBrush x:Key="GlyphBrush" Color="#FFF" />

    <SolidColorBrush x:Key="LightColorBrush" Color="#DDD" />

    <Style x:Key="ScrollBarLineButton" TargetType="{x:Type RepeatButton}" >
        <Setter Property="SnapsToDevicePixels" Value="True"/>
        <Setter Property="OverridesDefaultStyle" Value="true"/>
        <Setter Property="Focusable" Value="false"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type RepeatButton}">
                    <Border 
                          Name="Border"
                          Margin="1" 
                          CornerRadius="2" 
                          Background="{DynamicResource NormalBrush}"
                          BorderBrush="{DynamicResource NormalBorderBrush}"
                          BorderThickness="1">
                        <Path 
                                HorizontalAlignment="Center"
                                VerticalAlignment="Center"
                                Fill="{DynamicResource GlyphBrush}"
                                Data="{Binding Path=Content,RelativeSource={RelativeSource TemplatedParent}}" />
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsPressed" Value="true">
                            <Setter TargetName="Border" Property="Background" Value="{DynamicResource PressedBrush}" />
                        </Trigger>
                        <Trigger Property="IsEnabled" Value="false">
                            <Setter Property="Foreground" Value="{DynamicResource DisabledForegroundBrush}"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="ScrollBarPageButton" TargetType="{x:Type RepeatButton}">
        <Setter Property="SnapsToDevicePixels" Value="True"/>
        <Setter Property="OverridesDefaultStyle" Value="true"/>
        <Setter Property="IsTabStop" Value="false"/>
        <Setter Property="Focusable" Value="false"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type RepeatButton}">
                    <Border Background="Transparent" />
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="ScrollBarThumb" TargetType="{x:Type Thumb}">
        <Setter Property="SnapsToDevicePixels" Value="True"/>
        <Setter Property="OverridesDefaultStyle" Value="true"/>
        <Setter Property="IsTabStop" Value="false"/>
        <Setter Property="Focusable" Value="false"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Thumb}">
                    <Border 
          CornerRadius="2" 
          Background="{TemplateBinding Background}"
          BorderBrush="{TemplateBinding BorderBrush}"
          BorderThickness="1" />
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <ControlTemplate x:Key="VerticalScrollBar" TargetType="{x:Type ScrollBar}">
        <Grid >
            <Grid.RowDefinitions>
                <RowDefinition MaxHeight="18"/>
                <RowDefinition Height="0.00001*"/>
                <RowDefinition MaxHeight="18"/>
            </Grid.RowDefinitions>
            <Border
                      Grid.RowSpan="3"
                      CornerRadius="2" 
                      Background="Transparent" />
            <RepeatButton 
                  Grid.Row="0"                           
                  Style="{DynamicResource ScrollBarLineButton}"
                  Height="18"
                  Command="ScrollBar.LineUpCommand"
                  Content="M 0 4 L 8 4 L 4 0 Z" />
            <Track 
                  Name="PART_Track"
                  Grid.Row="1"
                  IsDirectionReversed="true">
                <Track.DecreaseRepeatButton>
                    <RepeatButton 
                      Style="{DynamicResource ScrollBarPageButton}"
                      Command="ScrollBar.PageUpCommand" />
                </Track.DecreaseRepeatButton>
                <Track.Thumb>
                    <Thumb 
          Style="{DynamicResource ScrollBarThumb}" 
          Margin="1,0,1,0"  
          Background="{DynamicResource HorizontalNormalBrush}"
          BorderBrush="{DynamicResource HorizontalNormalBorderBrush}" />
                </Track.Thumb>
                <Track.IncreaseRepeatButton>
                    <RepeatButton 
          Style="{DynamicResource ScrollBarPageButton}"
          Command="ScrollBar.PageDownCommand" />
                </Track.IncreaseRepeatButton>
            </Track>
            <RepeatButton 
      Grid.Row="3" 
      Style="{DynamicResource ScrollBarLineButton}"
      Height="18"
      Command="ScrollBar.LineDownCommand"
      Content="M 0 0 L 4 4 L 8 0 Z"/>
        </Grid>
    </ControlTemplate>

    <ControlTemplate x:Key="HorizontalScrollBar" TargetType="{x:Type ScrollBar}">
        <Grid >
            <Grid.ColumnDefinitions>
                <ColumnDefinition MaxWidth="18"/>
                <ColumnDefinition Width="0.00001*"/>
                <ColumnDefinition MaxWidth="18"/>
            </Grid.ColumnDefinitions>
            <Border
      Grid.ColumnSpan="3"
      CornerRadius="2" 
      Background="#F0F0F0" />
            <RepeatButton 
      Grid.Column="0"                           
      Style="{DynamicResource ScrollBarLineButton}"
      Width="18"
      Command="ScrollBar.LineLeftCommand"
      Content="M 4 0 L 4 8 L 0 4 Z" />
            <Track 
      Name="PART_Track"
      Grid.Column="1"
      IsDirectionReversed="False">
                <Track.DecreaseRepeatButton>
                    <RepeatButton 
          Style="{DynamicResource ScrollBarPageButton}"
          Command="ScrollBar.PageLeftCommand" />
                </Track.DecreaseRepeatButton>
                <Track.Thumb>
                    <Thumb 
          Style="{DynamicResource ScrollBarThumb}" 
          Margin="0,1,0,1"  
          Background="{DynamicResource NormalBrush}"
          BorderBrush="{DynamicResource NormalBorderBrush}" />
                </Track.Thumb>
                <Track.IncreaseRepeatButton>
                    <RepeatButton 
          Style="{DynamicResource ScrollBarPageButton}"
          Command="ScrollBar.PageRightCommand" />
                </Track.IncreaseRepeatButton>
            </Track>
            <RepeatButton 
      Grid.Column="3" 
      Style="{DynamicResource ScrollBarLineButton}"
      Width="18"
      Command="ScrollBar.LineRightCommand"
      Content="M 0 0 L 4 4 L 0 8 Z"/>
        </Grid>
    </ControlTemplate>

    <Style x:Key="{x:Type ScrollBar}" TargetType="{x:Type ScrollBar}">
        <Setter Property="SnapsToDevicePixels" Value="True"/>
        <Setter Property="OverridesDefaultStyle" Value="true"/>
        <Style.Triggers>
            <Trigger Property="Orientation" Value="Horizontal">
                <Setter Property="Width" Value="Auto"/>
                <Setter Property="Height" Value="18" />
                <Setter Property="Template" Value="{DynamicResource HorizontalScrollBar}" />
            </Trigger>
            <Trigger Property="Orientation" Value="Vertical">
                <Setter Property="Width" Value="18"/>
                <Setter Property="Height" Value="Auto" />
                <Setter Property="Template" Value="{DynamicResource VerticalScrollBar}" />
            </Trigger>
        </Style.Triggers>
    </Style>
</ResourceDictionary>